package com.example.comment.utils;

import com.example.comment.enums.SystemErrorEnum;

/**
 * @author QingZeyu
 * @date 2024/5/7 14:38
 */
public class SystemException extends RuntimeException{
    private Integer code;

    public SystemException(String message) {
        super(message);
        this.code = SystemErrorEnum.SYS_ERROR.getCode();
    }

    public SystemException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public SystemException(String message, Integer code) {
        super(message);
        this.code = code;
    }

    public SystemException(SystemErrorEnum systemError) {
        super(systemError.getMessage());
        this.code = systemError.getCode();
    }

    public SystemException(String message, Exception e) {
        super(message, e);
        this.code = SystemErrorEnum.FAILED.getCode();
    }

    public SystemException() {
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public Integer getCode() {
        return this.code;
    }
}
